//g++ test.cpp -l psapi
#include <windows.h>
#include <iostream>
#include <cstdlib>
#include <Psapi.h>
#include <TlHelp32.h>
#include <assert.h>
//#pragma comment(lib, "Iphlpapi")
//#pragma comment(lib, "Psapi")

int main(int argc, _TCHAR* argv[]){
    DWORD pdwPIDArray[512];
    DWORD dwPIDArraySize;
    EnumProcesses(pdwPIDArray, 512, &dwPIDArraySize);
    for(int i = 0; i < (int)dwPIDArraySize; ++ i){
        HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ|PROCESS_SET_QUOTA, 0, pdwPIDArray[i]);
        SetProcessWorkingSetSize(hProcess, -1, -1);
        EmptyWorkingSet(hProcess);
        CloseHandle(hProcess);
    }
    system("pause");
    return 0;
}
